<?php
class Myblog_Form_Registration extends Zend_Form
{

	public function init()
	{
 mb_internal_encoding("UTF-8");
 $this->addPrefixPath('Myblog_View_Helper', 'Myblog/View/Helper/');

	$this->setAction('/user/registration')
		->setMethod('post')
		->setName('registration')
		->setAttrib('onsubmit','return checkform()');

	$this->addElements(array(
		new Zend_Form_Element_Text('username',array(
			'label'=>'Имя:',
			'required'=>'true',
			'size'=>'24',
            'autocomplete'=>'off',
            'placeholder'=>'Введите ваше имя',
			'validators'=>array(
				array('StringLength',true,array(4,20)),
				array('NameValidator'),
				array('NotEmpty')),
			'filters'=>array(
				array('StripTags'),
				array('StringToLower'),
				array('StringTrim')	
				)
			)),


	new Zend_Form_Element_Text('userlogin',array(
			'label'=>'Логин:',
			'required'=>'true',
            'autocomplete'=>'off',
			'size'=>'24',
            'placeholder'=>'Введите Желаемый логин',
			'validators'=>array(
				array('StringLength',true,array(6,20)),
				array('NameValidator'),
				array('LoginUnique'),
				array('NotEmpty')),
			'filters'=>array(
				array('StripTags'),
				array('StringToLower'),
				array('StringTrim'))
	)),

	new Zend_Form_Element_Text('email',array(
		'label'=>'Ваш Email:',
		'required'=>'true',
		'size'=>'24',
        'autocomplete'=>'off',
        'placeholder'=>'Введите адрес вашей почты',
		'validators'=>array(
			array('StringLength',true,array(4,25)),
			array('EmailAddress'),
			array('EmailUnique'),
			array('NotEmpty')),
		'filters'=>array(
			array('StripTags'),
			array('StringToLower'),
			array('StringTrim'))
	)),

	new Zend_Form_Element_Password('confirmpassword',array(
		'label'=>'Повторите пароль:',
		'required'=>'true',
        'autocomplete'=>'off',
		'size'=>'24',
        'placeholder'=>'Повторите ваш пароль',
		'validators'=>array(
			array('StringLength',true,array(6,16)),
			array('Alnum'),
			array('ConfirmPassword'),
			array('PassVerify'),
			array('NotEmpty')),
			'filters'=>array(
			array('StripTags'),
			array('StringToLower'),
			array('StringTrim'))
	)),

	new Zend_Form_Element_Password('password',array(
		'label'=>'Пароль:',
		'required'=>'true',
        'autocomplete'=>'off',
		'size'=>'24',
        'placeholder'=>'Введите ваш пароль',
		'validators'=>array(
			array('StringLength',true,array(6,16)),
			array('Alnum'),
			array('PassVerify'),
            array('ConfirmPassword'),
			array('NotEmpty')),
			'filters'=>array(
			array('StripTags'),
			array('StringToLower'),
			array('StringTrim'))
	)),

	$captcha=new  Zend_Form_Element_Captcha('captcha',array(
			'label'=>'Введите капчу:',
			'size'=>5,
            'autocomplete'=>'off',
			'required'=>true,
			'validators'=>array(array('NotEmpty')),
		'captcha'=>array(
			'captcha'=>'Image',
			'GcFreq'=>3,
			'wordLen'=>5,
			'timeout'=>300,
			'width'=>120,
			'height'=>60,
			'imgUrl'=>'images/captcha',
			'fontsize'=>22,
			'DotNoiseLevel'=>'5',
			'LineNoiseLevel'=>'5',
			'imgDir'=>APPLICATION_PATH . '/../public/images/captcha',
			'font'=>APPLICATION_PATH . '/../public/fonts/AA_typewriter.ttf'
			)
		)),

	$element=new Myblog_Form_Element_Link('link',array('attribs'=>array('text'=>'Обновить капчу','title'=>'Обновить капчу','href'=>'javascript:void(0)'))),
	$element->removeDecorator('Label'),
	
	new Zend_Form_Element_Submit('reg_submit',array(
		'label'=>'Регистрация',
        'class'=>'btn btn-primary',
        'data-check'=>0
		))
	));
	$this->addDisplayGroup(array('username','userlogin','email','password','confirmpassword','captcha','link','reg_submit'),'authDataGroup',array('legend'=>'Регистрация'));
	}
}
